import { Group, Object3D } from 'three';
import { IEditorHistoryOptions } from '../EditorHistory';
import EditorCommand, { EnumEditorCommandName, EnumEditorCommandType } from './EditorCommands';
export interface IEditorRemoveObjectCommandsOptions extends IEditorHistoryOptions {
    object: Group,
}
export default class EditorRemoveObjectCommands extends EditorCommand {
    object: Group;
    parent: Object3D | null | undefined;
    index: number | null = null;
    constructor(options: IEditorRemoveObjectCommandsOptions) {
        super(options);
        this.type = EnumEditorCommandType.RemoveObjectCommand;
        this.object = options.object;
        this.name = EnumEditorCommandName.RemoveObject;

        this.parent = options.object ? options.object.parent : undefined;
        if (this.parent) {
            this.index = this.parent.children.indexOf(this.object);
        }
    }

    execute() {
        this.editor.sceneMoveObject3DList = this.editor.sceneMoveObject3DList.filter(item => item.uuid !== this.object.uuid);
        this.editor.historyStore.removeObject(this.object);
        this.editor.deselectMeshGroupFunction();
    }

    undo() {
        this.editor.sceneMoveObject3DList.push(this.object);
        this.editor.historyStore.addObject(this.object);
        this.editor.selectMeshGroupFunction(this.object);
    }

    update(params: this) {
        throw new Error("Method not implemented.");
    }
}